
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Emil Yosifov (eey9)
 */
class KeyListen implements KeyListener{

    Frame frame;
    public KeyListen(Frame passedFrame) {
        frame = passedFrame;
    }
    
    public void keyTyped(KeyEvent ke) {
        int keyCode = ke.getKeyCode();
        if ( keyCode == KeyEvent.VK_Q ){
            System.out.println("You typed Q");
            frame.setText("You typed Q");
        }
        else {
            System.out.println("You typed something else");
            frame.setText("You typed something else");
        }
    }

    public void keyPressed(KeyEvent ke) {
      
        int keyCode = ke.getKeyCode();
        if ( keyCode == KeyEvent.VK_Q ){
            System.out.println("You pressed Q");
            frame.setText("You pressed Q");
        }
        else {
            System.out.println("You pressed something else");
            frame.setText("You pressed something else");
        }
        
    }

    public void keyReleased(KeyEvent ke) {
        int keyCode = ke.getKeyCode();
        if ( keyCode == KeyEvent.VK_Q ){
            System.out.println("You released Q");
        }
        else {
            System.out.println("You released something else");
        }
        frame.setText("No key is pressed");
    }
}
